#pragma once

#include <vector>
#include "config.h"
using namespace std;

class Uses{
public:
	/** Constructor
	 * Creates an empty Uses table.
	 */
	Uses();

	/**
	 * Add a new Uses relationship by statement.
	 * @param stmtNumber statement number that uses the corresponding variable.
	 * @param varIndex index of variable.
	 * @return the index of newly added Uses relationship, -1 if unsuccessful.
	 */
	int addUsesStatement(int stmtNumber, int varIndex);

	/**
	 * Add a new Uses relationship by procedure.
	 * @param procIndex index of the procedure.
	 * @param varIndex index of variable.
	 * @return the index of newly added Uses relationship, -1 if unsuccessful.
	 */
	int addUsesProcedure(int procIndex, int varIndex);

	/**
	 * Get list of all matching statement numbers and variable numbers.
	 * @param stmtNumber statement number of the statement, also accept ANYVALUE.
	 * @param varIndex index of variable, also accept ANYVALUE.
	 * @return a vector of pairs of statement number and variable index that satisfies the criteria, empty if none satisfies.
	 */
	vector<pair<int, int>> getUsesStatement(int stmtNumber, int varIndex);

	/**
	 * Get list of all matching procedure numbers and variable index.
	 * @param procIndex index of procedure, also accept ANYVALUE.
	 * @param varIndex index of variable, also accept ANYVALUE.
	 * @return a vector of pairs of procedure index and variable index that satisfies the criteria, empty if none satisfies.
	 */
	vector<pair<int, int>> getUsesProcedure(int procIndex, int varIndex);

private:
	vector<pair<int, int>> usesStmtIndex; /**< An Uses table that contains all pairs of statment number and variable index. */
	vector<pair<int, int>> usesProcIndex; /**< An Uses table that contains all pairs of procedure index and variable index. */
};

